// 题意：给定n个数，支持区间修改，区间查询
//
// 题解：线段树的话裸。可以用树状数组来写。只要再维护delta[i]
//       表示[i..n]这个区间增加差量这么多。然后推一下公式，
//       只要维护delta[i]以及delta[i] * i这两个就行，用两个树状数组维护。
//
// 统计：36ms, 30min, 1A
//
// run: $exec < input
#include <cstdio>

int const maxn = 100007;
long long da[maxn];
long long prefix_sum[maxn];
long long tree_delta[maxn], tree_delta_s[maxn]; // delta * self(i)
int n, q;

int lowbit(int x) { return x & -x; }

long long query(int x)
{
	long long sum = prefix_sum[x];
	int tx = x;
	for (; x; x -= lowbit(x))
		sum += (long long)(tx + 1) * tree_delta[x] - tree_delta_s[x];
	return sum;
}

void update(int x, int d)
{
	int tx = x;
	for (; x <= n; x += lowbit(x)) {
		tree_delta[x] += d;
		tree_delta_s[x] += d * tx;
	}
}

int main()
{
	std::scanf("%d %d", &n, &q);
	for (int i = 1; i <= n; i++) std::scanf("%lld", &da[i]);
	for (int i = 1; i <= n; i++) prefix_sum[i] = prefix_sum[i - 1] + da[i];

	for (int i = 0, l, r, d; i < q; i++) {
		char ch;
		std::scanf("\n%c", &ch);
		if (ch == 'Q') {
			std::scanf("%d %d", &l, &r);
			std::printf("%lld\n", query(r) - query(l - 1));
		} else {
			std::scanf("%d %d %d", &l, &r, &d);
			update(l, d);
			update(r + 1, -d);
		}
	}
}

